#!/bin/bash

function info() {
echo Usage: `basename $0` '[-m(emory)G] <input.bam> <interval.bed>'
exit 2
}

while getopts  ":Gp:m:" opts
do
	case  $opts  in
	p) out_prefix=$OPTARG;;	
	G) no_genes_stat='true';;
    m) mem=$OPTARG;;	
	?) info;;
	esac
done
shift $(($OPTIND - 1))


if [ -z "$2" ]; then info;  fi


. $var


if [ -z $out_prefix ]; then
	out_prefix=1.gatk.depth
fi


# data_thread_num=10
# cpu_thread_num=4

stat_gatk.sh -i $2 $1
cov_stat1.py -g $2 $out_prefix.callable_status.bed # bed file must be sorted and -g bed file must has 4 fields


if test "$no_genes_stat" = "true"; then

echo;echo;echo gatk summary
$java_run/gatk \
   -T DepthOfCoverage \
   -R $ref_genome \
   -o $out_prefix \
   --omitDepthOutputAtEachBase \
   --omitLocusTable \
   --outputFormat csv \
   -I $1 \
   -L $2 \
   -ct 1 -ct 10 -ct 30 -ct 100
   
else 
   
echo;echo;echo gatk summary
$java_run/gatk \
   -T DepthOfCoverage \
   -R $ref_genome \
   -o $out_prefix \
   -geneList ${data_path}/all.rq \
   --omitDepthOutputAtEachBase \
   --omitLocusTable \
   --outputFormat csv \
   -I $1 \
   -L $2 \
   -ct 1 -ct 10 -ct 30 -ct 100
   
fi
   

   
# [-geneList refSeq.sorted.txt] \
# [-pt readgroup] \

. $cmd_done